<template>
  <a-spin :spinning="loading">
    <!-- 首页页面 -->
    <generate-form insite="true" v-if="this.showPortletList" :data="currentWidgetForm" ref="generateForm"></generate-form>
  </a-spin>
</template>

<script>

  import '@/framework/FormMaking/styles/cover.less'
  import GenerateForm from '@/framework/FormMaking/components/portletDesignEditor/GenerateForm'
  import {getAction } from '@/api/manage'
  import YchConstant from "@/api/YchConstant";

  export default {
    name: "Portal",
    components: {
      GenerateForm
    },
    data() {
      return {
        loading: false,
        showPortletList:false,
        defaultWidgetForm: {
          list: [
          ],
          config: { labelWidth: 100, labelPosition: 'right', size: 'small' }
        },
        currentWidgetForm:{},
        url:{
          queryPortletBySelf:YchConstant.PREFIX_SYSTEM + "/portlet/queryPortletBySelf",
        }
      }
    },
    created() {
      this.queryPortletBySelf();
    },
    methods: {
      queryPortletBySelf(){
        this.loading = true
        getAction(this.url.queryPortletBySelf, null).then(res => {
          if (res.success) {
            if(res.result.currentPortletConfig && res.result.currentPortletConfig !== 'null'){
              const currentWidgetForm = JSON.parse(res.result.currentPortletConfig.content)
              this.currentWidgetForm = currentWidgetForm || this.defaultWidgetForm
              this.showPortletList = true
            }
          } else {
          }
          this.loading = false
        })
      },
    }
  }
</script>

<style lang="less" scoped>
  ul.ant-dropdown-menu{
    left: -45px;
    top: 4px;

  }
  ul:before{
    content: "";
    position: absolute;
    top: -16px;
    left: 35px;
    margin-left: -9px;
    width: 0px;
    height: 0px;
    border-style: solid;
    border-width: 10px 10px 10px 10px;
    border-color: transparent transparent #ffffff transparent;
    z-index: 0;
  }
  li{
    display: flex;
    align-items: center;
    padding: 8px 10px;
  }

  li {
    display: inline-flex;
    width: 133px;
    position: relative;
    align-items: center;
  }
  .tabs-drop-item-span{
    white-space: nowrap;
    text-overflow: ellipsis;
    width: 80px;
    height: 24px;
    display: inline-block;
    overflow: hidden;
    vertical-align: text-bottom;
  }
  i{
    color: #b9bcb6;
    position: absolute;
    right: 10px
  }


</style>
